import time as t

def test():
    text = "I love FishC.com!"
    char = 'o'
    if char in text:
            pass


class Mytimer:
    def __init__(self,name,time=1000000):
        self.prompt = "未开始计时！"
        self.name = name
        self.time=time
        self.total = 0
        self.default_timer = t.perf_counter
        
    def __str__(self):
        return self.prompt

    __repr__=__str__
    def __add__(self,other):
        last1=self.total+other.total
        lastpt='总共用:%0.2f秒' %last1
        return lastpt
    
    def timing(self):
        self.begin =self.default_timer()
        for each in range(self.time):
            self.name()
        self.end = self.default_timer()
        self.total=self.end-self.begin
        self.prompt = "总共运行了 %0.2f 秒" % self.total


    def set_timer(self,timer):
        if timer == 'process_time':
            self.default_timer = t.process_time
        elif timer == 'perf_counter':
            self.default_timer = t.perf_counter
        else :
            print('输入错误 请输入process_time或perf_counter')
            
        

